/**
 * 1 位共阳数码管
 */
#define NIXIE_V 2
#define NIXIE_A 3
#define NIXIE_B 4
#define NIXIE_C 5
#define NIXIE_D 6
#define NIXIE_E 7
#define NIXIE_F 8
#define NIXIE_G 9

int numMap[10][8] = {
  {1, 0, 0, 0, 0, 0, 0, 1}, // 0
  {1, 1, 0, 0, 1, 1, 1, 1}, // 1
  {1, 0, 0, 1, 0, 0, 1, 0}, // 2
  {1, 0, 0, 0, 0, 1, 1, 0}, // 3
  {1, 1, 0, 0, 1, 1, 0, 0}, // 4
  {1, 0, 1, 0, 0, 1, 0, 0}, // 5
  {1, 0, 1, 0, 0, 0, 0, 0}, // 6
  {1, 0, 0, 0, 1, 1, 1, 1}, // 7
  {1, 0, 0, 0, 0, 0, 0, 0}, // 8
  {1, 0, 0, 0, 0, 1, 0, 0}  // 9
};

void displayNum(int num);

void setup() {
  // put your setup code here, to run once:
  pinMode(NIXIE_V, OUTPUT);
  pinMode(NIXIE_A, OUTPUT);
  pinMode(NIXIE_B, OUTPUT);
  pinMode(NIXIE_C, OUTPUT);
  pinMode(NIXIE_D, OUTPUT);
  pinMode(NIXIE_E, OUTPUT);
  pinMode(NIXIE_F, OUTPUT);
  pinMode(NIXIE_G, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  for (int i=0;i<10;i++){
    displayNum(i);
    delay(1000);
  }
}

void displayNum(int num){
  if (num > 9 || num < 0){
    return ;
  }
  digitalWrite(NIXIE_V, numMap[num][0] ? HIGH : LOW);
  digitalWrite(NIXIE_A, numMap[num][1] ? HIGH : LOW);
  digitalWrite(NIXIE_B, numMap[num][2] ? HIGH : LOW);
  digitalWrite(NIXIE_C, numMap[num][3] ? HIGH : LOW);
  digitalWrite(NIXIE_D, numMap[num][4] ? HIGH : LOW);
  digitalWrite(NIXIE_E, numMap[num][5] ? HIGH : LOW);
  digitalWrite(NIXIE_F, numMap[num][6] ? HIGH : LOW);
  digitalWrite(NIXIE_G, numMap[num][7] ? HIGH : LOW);
}
